Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Customer Configurable Standardization #53

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

rmi22186
Copy link
Collaborator

@rmi22186 rmi22186 commented Sep 25, 2023

Summary

This PR allows a customer to pass a standardization callback for name that affects event name, custom attributes, and product attributes.

Testing Plan

Added unit tests. Tested locally.

The callback I used was to remove the last letter of each string.

Screen shot 1 shows a transaction sent with product attributes and custom attributes.
image
Note that eventMetric1 gets shortened to eventMetric in the payload. journeyType --> journeyTyp, and sale --> sal.

Screenshot 2
image
Shows name --> nam, abc --> ab, and def --> de.

Master Issue

Closes https://go.mparticle.com/work/SQDSDKS-5641

Copy link
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM me logic wise but I'll leave it to Alex for a final approval of the code

packages/GA4Client/src/common.js Outdated Show resolved Hide resolved
name = window.GoogleAnalytics4Kit.setCustomNameStandardization(name);
} catch (e) {
console.warn(
'Error calling setCustomNameStandardization callback. Check your callback. Data will still be sent without user-defined standardization',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide a link to our docsite? If not in the error log, perhaps we can provide a link to the docsite or example code as a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't started the docs yet. But that's a good idea.

Comment on lines 26 to 30
// Due to current limitations, the API for allowing a customer to cleanse
// their data before our cleansing occurs must be placed on the
// window.GoogleAnalytics4Kit object. This exists when initializing MP
// SDK via snippet, but not via npm. If a customer uses npm, using the API
// requires window.GoogleAnalytics4Kit to exist on the page.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial part is a little unclear. Does this make more sense?

Suggested change
// Due to current limitations, the API for allowing a customer to cleanse
// their data before our cleansing occurs must be placed on the
// window.GoogleAnalytics4Kit object. This exists when initializing MP
// SDK via snippet, but not via npm. If a customer uses npm, using the API
// requires window.GoogleAnalytics4Kit to exist on the page.
// To allow customers to cleanse their data before mParticle
// internal cleansing occurs, we must add a simple API into the
// window.GoogleAnalytics4Kit object. This object will be automatically
// initialized when MP SDK initializes via snippet, but not via npm.
// Customers using npm, a customer must manually add
// window.GoogleAnalytics4Kit to the page themselves.

@rmi22186 rmi22186 merged commit 712f23a into development Sep 26, 2023
4 checks passed
@rmi22186 rmi22186 deleted the feat/SQDSDKS-5641-cleansing-callback branch September 26, 2023 19:02
github-actions bot pushed a commit that referenced this pull request Oct 2, 2023
# [1.3.0](v1.2.0...v1.3.0) (2023-10-02)

### Features

* Add Customer Configurable Standardization ([#53](#53)) ([c851914](c851914))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants